﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using BEGDC.Utility.Security;
using BEGDC.Utility.Configuration;

namespace ASB.PreContract.Test
{
    /// <summary>
    /// Summary description for UnitTest1
    /// </summary>
    [TestClass]
    public class EncryptTest
    {
        public EncryptTest()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        [TestMethod]
        public void EncryptConnection()
        {
            //Data Source=vs12prec01;Initial Catalog=PreContract2;User ID=sa;Password=***********
            //Q0yXI/MFezvxxrURAPQxQsTu1oZullQEvUkzcS9P314RzQe5206h8ADBHTAjSZw2/Aw+5VZKSN5rPAbNYaOAXcogEHjU5A/rK2XizWXv9fWVvJHWwYLzSQ==
            var s = EncryptTool.Encrypt("Data Source=vs12prec01;Initial Catalog=PreContract2;User ID=sa;Password=asb!2345", ConfigConst.Key);
            TestContext.WriteLine(s);
        }


        [TestMethod]
        public void DecryptConnection()
        {
            //UID=ecm;Password=ecm;Initial Catalog=precontractnew;Data Source=135.251.32.158
            var s = EncryptTool.Decrypt("cZqKOSZUEQcxklKx3gZurajG7wFZtjiiTq3am9SppfepxAAtoC74hy8UZwHvkTnZxxGDac5hXPXyhHfPYPwLzbOsPy42z+r6mvYQ2J6ob7g=", ConfigConst.Key);
            TestContext.WriteLine(s);
        }
    }
}
